import 'package:flutter/material.dart';
import 'package:gzmall_app/common/color_common.dart';

class InputContentPage extends StatefulWidget {
  String _title;

  InputContentPage(this._title);

  @override
  State<StatefulWidget> createState() {
    return InputContentPageState(_title);
  }
}

class InputContentPageState extends State<InputContentPage> {
  String _content;
  String _title;

  TextEditingController _contentController = TextEditingController();

  InputContentPageState(this._title);

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _createAppBar(_title),
      body: new Container(
        height: 54.0,
        padding: const EdgeInsets.only(left: 20.0, right: 20.0),
        margin: const EdgeInsets.only(top: 20.0, bottom: 20.0),
        alignment: Alignment.center,
        decoration: new BoxDecoration(color: Colors.white),
        child: new Row(
          children: <Widget>[
            new Expanded(
              child: new TextField(
                controller: _contentController,
                style: new TextStyle(color: ColorCommon.black1),
                decoration: new InputDecoration.collapsed(
                  hintText: "请输入内容",
                  hintStyle:
                      TextStyle(fontSize: 12.0, color: ColorCommon.grey1),
                ),
                onChanged: (str) {
                  _content = str ?? '';
                },
              ),
            ),
          ],
        ),
      ),
    );
  }

  _createAppBar(String title) {
    return AppBar(
      elevation: 0.0,
      title: Text(title ?? "输入内容"),
      leading: IconButton(
        icon: Icon(Icons.arrow_back_ios),
        onPressed: () {
          Navigator.of(context).pop();
        },
      ),
      actions: <Widget>[
        GestureDetector(
          onTap: () {
            Navigator.of(context).pop(_content);
          },
          child: Container(
            child: Text("完成"),
            alignment: Alignment.center,
            padding: const EdgeInsets.only(right: 15.0),
          ),
        ),
      ],
    );
  }
}
